import request from '@/utils/request';

/**
 * 查询门店列表
 *
 * @param {object} query 查询参数Obj
 * @returns
 */
export const listDept = async (query?: any) => request({
	url: '/system/dept/list',
	method: 'get',
	params: query,
});

/**
 * 查询门店分页列表
 *
 * @param {object} query 查询参数Obj
 * @returns
 */
export const page = async (query?: any) => request({
	url: '/system/dept/page',
	method: 'get',
	params: query,
});

/**
 * 查询门店列表（排除节点
 *
 * @param {string} deptId 门店ID
 * @returns
 */
export const listDeptExcludeChild = async (deptId: string) => request({
	url: '/system/dept/list/exclude/' + deptId,
	method: 'get',
});

/**
 * 查询门店详细
 *
 * @param {string} deptId 门店ID
 * @returns
 */
export const getDept = async (deptId: string) => request({
	url: '/system/dept/' + deptId,
	method: 'get',
});

/**
 * 查询门店下拉树结构
 *
 * @returns
 */
export const treeselect = async () => request({
	url: '/system/dept/treeselect',
	method: 'get',
});

/**
 * 根据角色ID查询门店树结构
 *
 * @param {string} roleId 角色ID
 * @returns
 */
export const roleDeptTreeselect = async (roleId: string) => request({
	url: '/system/dept/roleDeptTreeselect/' + roleId,
	method: 'get',
});

/**
 * 新增门店
 *
 * @param {object} param 门店Obj
 * @returns
 */
export const addDept = async (param: any) => request({
	url: '/system/dept',
	method: 'post',
	data: param,
});

/**
 * 修改门店
 *
 * @param {object} data 门店Obj
 * @returns
 */
export const updateDept = async (data: any) => request({
	url: '/system/dept',
	method: 'put',
	data,
});

/**
 * 删除
 *
 * @param {string} deptId 门店Id
 * @returns
 */
export const delDept = async (deptId: string) => request({
	url: '/system/dept/' + deptId,
	method: 'delete',
});

/**
 * 批量删除
 *
 * @param {string} deptIds 门店Id数组
 * @returns
 */
export const batchDelDept = async (deptIds: string) => request({
	url: '/system/dept/batchDel/' + deptIds,
	method: 'delete',
});
